package servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import domein.Student;
import IO.*;

@WebServlet(name="ToonStudentGegevensSevlet", urlPatterns="/ToonStudentGegevens.do")
public class ToonStudentGegevensServlet extends HttpServlet   {
	private static final long serialVersionUID = 1L;
 
	/**
	 * @see HttpServlet#HttpServlet()
	 */

	public ToonStudentGegevensServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	protected void doGet(HttpServletRequest req, HttpServletResponse response) 
			throws ServletException, IOException {
		DatabaseIO d = new DatabaseIO();
		String emailStudent = req.getParameter("student");
			for (Student s : d.listStudenten()) {
				if(s.getEmail().equals(emailStudent)){
					req.getSession().setAttribute("student", s);
				}
			}
		response.sendRedirect("Gegevens_student.jsp");
		d.sluitDbVerbinding();
		}
	}

